<!--
 * Date: 2018年10月23日 13:28:06
 * LastEditors  : lvyou
 * LastEditTime : 2020年01月14日 11:44:54
 * FilePath: \youlinweb-master\src\pages\topic\topicdetail\activityrule\activityrule.vue
 * copyright(c) 2019-2025 版权为浙江双城网络科技集团有限公司所有，违者必究。
 -->
<template>
<div >
    <ylheader :leftsvg='true' :title="headtitle" ></ylheader>
    <div class="loadmore-container" ref="activityruleWrapper" :class="{'height-auto':heightauto}">
      <div class="loadmore-ul">
        <div class="shuoshuo-new" v-if="listnodata">
            <span class="yl-2kong nosvg">
            <span class="path1">
                <span class="path2">
                <span class="path3">
                    <span class="path4">
                    <span class="path5">
                        <span class="path6">
                        <span class="path7">
                            <span class="path8">
                            <span class="path9"></span>
                            </span>
                        </span>
                        </span>
                    </span>
                    </span>
                </span>
                </span>
            </span>
            </span>
            <span class="no-text">还没有相关内容哦~</span>
        </div>
        <div v-else class="whiteback">
            <div class="flex titleline" v-if="title">
                <div v-if="headtitle=='投稿详情'"></div>
                <p class="detail_title" >{{title}}</p>
            </div>
            <div id="topicDetailHtml"  v-html="html" class="activity_rule_detail"></div>
        </div>
      </div>
    </div>
    <p style="padding-bottom:20px"></p>
</div>
</template>
<script>
import api from "src/api/index";
import ylheader from "src/components/yl-header.vue";
import {privacy} from "./privacy.js";
export default {
  name:"activityrule",
  data(){
      return{
         html:"",
         headtitle:"",
         title:"",
         listnodata:false,
         topicId:"",
         privacy:privacy[0],
         heightauto:false
      }
  },
  components:{
      api,
      ylheader
  },
  mounted(){
      this.init();
  },
  methods:{
      init(){
          if(this.$route.query.tag==0){
              this.headtitle="活动规则";
              this.topicId = this.$route.query.topicId;
              this.getactivityrule().then(data => {
                    return this.initScroll();
              }).then(data => {
                this.irefresh();
              });
          }else if(this.$route.query.tag==1){
              this.headtitle="使用帮助";
              this.getusehelpinfo().then(data => {
                    return this.initScroll();
                }).then(data => {
                    this.irefresh();
              });
          }else if(this.$route.query.tag==3){
              this.headtitle="抽奖规则";
              this.getrotaterule().then(data => {
                    return this.initScroll();
                }).then(data => {
                    this.irefresh();
              });
          }else if(this.$route.query.tag==4){
                this.headtitle="签到规则";
                 this.querySignRule().then(data => {
                    return this.initScroll();
                }).then(data => {
                    this.irefresh();
              });
          }else if(this.$route.query.tag==5){
                this.headtitle="兑换规则";
                 this.getExchangeRule().then(data => {
                    return this.initScroll();
                }).then(data => {
                    this.irefresh();
              });
          }else if(this.$route.query.tag==6){
                this.headtitle="说说版规";
                this.html = this.$route.params.saysRuleContent;
                this.initScroll()
          }else if(this.$route.query.tag==7){
                this.headtitle="闲置版规";
                this.html = this.$route.params.replacedRuleContent;
                this.initScroll()
          }else if(this.$route.query.tag==8){
                this.headtitle="投稿说明";
                this.html = this.$route.params.articlesContent;
                this.initScroll()
          }else if(this.$route.query.tag==9){
                this.headtitle="投稿详情";
                this.queryArticles().then(data => {
                    return this.initScroll();
                }).then(data => {
                    this.irefresh();
                });
          }else if(this.$route.query.tag==10){
              this.headtitle="隐私政策";
              this.heightauto=true;
              this.html=decodeURIComponent(this.privacy)
          }
      },
        irefresh(){
            this.$nextTick(() => {
                setTimeout(() => {
                    this.myscroll.refresh();
                }, 2500);
            });
        },
       getExchangeRule(){
            let p = new Promise((resolve, reject) => {
                api.getExchangeRule().then(res=>{
                     if(res.success){
                         this.html = res.data;
                         if(this.html==null||this.html==""){
                             this.listnodata = true;
                         }else{
                             this.listnodata = false;
                         }
                     }
                    resolve("获取兑换规则....");
                })
            })
            return p;
       } ,
       getusehelpinfo(){
            let p = new Promise((resolve, reject) => {
                const params = {id:this.$route.query.id}
                api.getusehelpinfo(params).then(res=>{
                     if(res.success){
                         this.title = res.data.title;
                         this.html = res.data.content;
                         if(this.title==null&&this.html==null){
                             this.listnodata = true;
                         }else{
                             this.listnodata = false;
                         }
                     }
                    resolve("获取规则内容....");
                })
            })
            return p;
       } ,
       getactivityrule(){
            let p = new Promise((resolve, reject) => {
                const params={id:this.topicId};
                api.Querytopicdetail(params).then(res => {
                    if(res.success){
                        this.html = res.data.topic[0].topicRule;
                        this.showempty();
                    }
                    resolve("获取帮助内容....");
                })
            })
            return p;
       },
       showempty(){
        if(this.html==""||this.html==null){
            this.listnodata = true;
        }else{
            this.listnodata = false;
        }
       },
       getrotaterule(){
            let p = new Promise((resolve, reject) => {
               api.getdraw({drawId:this.$route.query.drawId}).then(res=>{
                    if(res.success){
                        this.html = res.data.rule;
                        this.showempty();
                    }
                     resolve("获取抽奖规则....");
                })
            })
            return p;
       },
        //查询签到规则
       querySignRule(){
            let p = new Promise((resolve, reject) => {
               api.querySignRule().then(res=>{
                    if(res.success){
                        this.html = res.data;
                        this.showempty();
                    }
                    resolve("获取签到规则....");
                })
            })
            return p;
       },
        //查询投稿文章
       queryArticles(){
            let p = new Promise((resolve, reject) => {
               api.queryArticles({articlesId:this.$route.query.articlesId}).then(res=>{
                    if(res.success){
                        this.title = res.articles.title;
                        this.html = res.articles.content;
                        this.showempty();
                    }
                    resolve("获取投稿文章....");
                })
            })
            return p;
       },

           //初始化scroll
    initScroll() {
      let p = new Promise((resolve, reject) => {
        let activityruleWrapper = this.$refs.activityruleWrapper;
        localStorage.tempPageHeight = document.getElementsByClassName(
          "loadmore-ul"
        )[0].scrollHeight;
        let _this = this;
        this.$nextTick(() => {
          _this.myscroll = new iScroll(activityruleWrapper, {
            preventDefault: false,
            onScrollMove: function() {
            },
            onScrollEnd: function() { },
            onScrollStart: function() {
              if (
                localStorage.tempPageHeight !=
                document.getElementsByClassName("loadmore-ul")[0].scrollHeight
              ) {
                this.refresh();
                localStorage.tempPageHeight = document.getElementsByClassName(
                  "loadmore-ul"
                )[0].scrollHeight;
              }
            }
          });
          resolve("初始化scroll");
        });
      });
      return p;
    },

  }
}
</script>
<style lang="less" scoped>

.activity_rule_detail{
    font-size: 0.28rem;
    color:#3a3a3a;
    padding: 0.25rem 0.42rem;
    word-wrap:break-word;
    word-break:break-all;
     background-color: white;
    line-height:0.52rem
}
.detail_title{
    padding: 0 0.3rem;
    margin: 0;
    width: 100%;
    background-color: white;
    font-size: 0.4rem;
    color:#3A3A3A;
}
.titleline{
   padding-top: 0.3rem;
    div{
        background: #FDDB43;
        width: 3px;
    }
}

</style>
<style lang="less" >
    .height-auto{
        height: auto;
    }
</style>


